package com.matrix.java.chap_05;

import java.util.Scanner;

/*
    游戏：石头、剪刀、布
 */
public class Ex5_34 {
    public static void main(String[] args) {
        int personWin = 0;
        int AIWin = 0;
        do {
            int randomNum = (int) (Math.random() * 3);
            String computer = getString(randomNum);
            System.out.println(randomNum);
            Scanner input = new Scanner(System.in);
            System.out.print("scissor (0) , rock (1), paper (2): ");
            int guessNum = input.nextInt();
            String person = getString(guessNum);
            int result = randomNum - guessNum;
            switch (result) {
                case -2:
                case 1:
                    System.out.println("The computer is " + computer + ". You are " + person + ". You loss");
                    AIWin++;
                    break;
                case -1:
                case 2:
                    System.out.println("The computer is " + computer + ". You are " + person + ". You win");
                    personWin++;
                    break;
                case 0:
                    System.out.println("The computer is " + computer + ". You are " + person + " too. It is a draw");
                    break;
            }
        } while (personWin < 2&&AIWin<2);
        System.out.println("完全赢了");
    }

    private static String getString(int guessNum) {
        String string = null;
        switch (guessNum) {
            case 0:
                string = "scissor";
                break;
            case 1:
                string = "rock";
                break;
            case 2:
                string = "paper";
                break;
        }
        return string;
    }
}

